﻿namespace B.S.BasicData.Common
{
    /// <summary>
    /// 拓展类
    /// 定义拓展方法
    /// 用this作为类型拓展的关键字
    /// 雷和方法必须都是静态的static
    /// </summary>
    public static class Extensions
    {
        /// <summary>
        /// 拓展字符串转成数字
        /// </summary>
        /// <param name="values"></param>
        /// <returns></returns>
        public static int Toint32(this string? values)
        {
            if(values == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(values);
            }
        }
        /// <summary>
        /// 根据身份证计算出生年月日
        /// </summary>
        /// <param name="CardId"></param>
        /// <returns></returns>
        public static string GetCard(this string? CardId)
        {
            string result = CardId.Substring(6,8);
            return result;
        }

        //public static string GetDateTime(this DateTime? date)
        //{
        //    return  date.ToString("yyyy--mm--dd");
           
        //}
    }
}
